import {createRouter, createWebHistory} from "vue-router";

const routes = [
    {
        path:'/',
        component: import('../components/root.vue'),
        // 将默认路由重定向到指定路由
        // 方式一，只能重定向path
        // redirect:"user1",
        // 方式二，可以带参数
        // redirect: {
        //     path:"/user1",
        //     query: {
        //         name: "小满"
        //     }
        // },
        alias: ['/root', '/root1', '/root2'],
        children: [
            {
                path:"user1",
                components: {
                    default() {
                        return import('../components/A.vue');
                    }
                }
            },
            {
                path:"user2",
                components: {
                    bbb() {
                        return import('../components/B.vue');
                    },
                    ccc() {
                        return import('../components/C.vue');
                    }
                }
            }
        ]
    }
]

const router = createRouter({
    history:createWebHistory(),
    routes
})

export default router